<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    canvas {
      border: 1px solid #ccc;
    }
  </style>
</head>

<body>
  <canvas width="600" height="400"></canvas>

</body>
<script>
  //画布
  let canvas = document.querySelector("canvas")
  //画笔（上下文）
  let ctx = canvas.getContext("2d")

  // ctx.arc(300,200,100,0,Math.PI/180*180,true)     //半圆

  //圆弧的路径
  ctx.arc(300, 200, 100, 0, Math.PI / 180 * 90, true)     //半圆
  ctx.lineTo(300,200)
  // ctx.lineTo(400,200)
  ctx.closePath()         //闭合路径

  //描边
  ctx.strokeStyle = "red"
  ctx.stroke()

  //填充
  ctx.fillStyle="purple"
  ctx.fill()
</script>

</html>